package com.yisu.expressway.api.web.util;

import com.google.common.collect.Lists;
import com.yisu.expressway.api.domain.vo.GoodsCategoryVo;
import com.yisu.expressway.ewf.entity.GoodsCategory;
import org.apache.commons.collections.CollectionUtils;

import java.util.List;

/**
 * Created by xlt on 2017/5/3.
 */
public class GoodsCategoryUtil {
    /**
     * 通用转换model方法
     *
     * @param sourceList 原modelList
     * @return
     */
    public List<GoodsCategoryVo> switchModel(List<GoodsCategory> sourceList) {
        List<GoodsCategoryVo> goodsCategoryVos = Lists.newArrayList();
        if (!CollectionUtils.isEmpty(sourceList)) {
            for (GoodsCategory item : sourceList) {
                GoodsCategoryVo model = new GoodsCategoryVo();
                model.setId(item.getId());
                model.setSort(item.getSort());
                model.setCategoryCode(item.getCategoryCode());
                model.setCategoryName(item.getCategoryName());
                model.setDescription(item.getDescription());
                model.setParentCode(item.getParentCode());
                model.setImage(item.getImage());
                goodsCategoryVos.add(model);
            }
        }
        return goodsCategoryVos;
    }
}
